<?php
$host="localhost";
$user="root";
$pwd="root";
$nomDB="gl";
$lien=mysql_connect($host,$user,$pwd) or die ("connexion impossible");
mysql_select_db($nomDB, $lien);
session_start();
$login = $_POST['log'];
$pass = $_POST['password'];

$result1 = mysql_query("SELECT *FROM admin WHERE login ='".$login."' AND pwd ='".$pass."'");
$result2 = mysql_query("SELECT *FROM  manager WHERE login ='$login' AND pwd ='$pass'");
$result3 = mysql_query("SELECT *FROM  client WHERE login ='$login' AND password ='$pass'");

$num_rows1 =0;
$num_rows2 =0;
$num_rows3 =0;
while($data=mysql_fetch_array($result1))
{
	$idgetter1=$data['idadmin'];	
	$num_rows1++;
}

while ($data= mysql_fetch_array($result2))
{
	$idgetter2=$data['idmanager'];	
	$num_rows2++;
}


while ($data= mysql_fetch_array($result3))
{
	$idgetter3=$data['idcli'];	
	$num_rows3++;
}
if (($num_rows1 == 0)&&($num_rows2 == 0)&&($num_rows3==0)) {
    echo 'not available';
} 
else  if ($num_rows1 != 0)
    {
    $_SESSION['admin'] = $idgetter1;
    echo 'admin';
    
}
else  if ($num_rows2 != 0)
    {
    $_SESSION['manager'] = $idgetter2;
    echo 'manager';
    
}
else if ($num_rows3 != 0)
{
	$_SESSION['client'] =$idgetter3;
	echo 'client';
	}
?>
